package com.yenlien.traceyun.business.controller;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.yenlien.traceyun.business.service.rest.RestService;
import com.yenlien.traceyun.webase.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: bigwangy@sina.com
 * @create: 2020-07-21
 * @description:
 **/

@RestController
@RequestMapping(value = "test")
public class TestController extends BaseController {

    @Autowired
    private RestService restService;

    @RequestMapping(value = "map")
    public Object postMap(HttpServletRequest request) {
        List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("files");
        Map<String, Object> map = new HashMap<>();
        map.put("name", "test");
        return restService.postForm("http://traceyun-usercenter/config/upload", map, files);
    }


}
